import shortuuid

from auth.models.auth import Auth
from auth.models.local_auth import LocalAuth


def init_root_user(engine):
    user_id = shortuuid.uuid()
    conn = engine.connect()
    conn.execute(
        Auth.__table__.insert(),
        id=user_id,
        screen_name='root',
        type='admin',
        head_image=''
    )

    conn.execute(
        LocalAuth.__table__.insert(),
        login_name='root',
        type='admin',
        password=LocalAuth.encrypt_password('123456'),
        auth_id=user_id,
    )

    # user_id = shortuuid.uuid()
    # user = Auth(
    #     id=user_id,
    #     screen_name='root',
    #     type='admin',
    #     head_image='',
    # )
    # session.add(user)
    # local_auth = LocalAuth(login_name='root',
    #
    #                        type='admin',
    #                        password=LocalAuth.encrypt_password('123456'))
    # local_auth.auth = user
    #
    # session.add(local_auth)
